import { ref } from "vue";
import { api } from "@/api";

export function useOrders() {
  const orders = ref([]);
  const total = ref(0);

  async function getOrders(params: any) {
    const res = (
      await api.get(`/orders`, {
        params,
      })
    ).data;
    orders.value = res?.data?.list ?? [];
    total.value = res?.data?.total ?? 0;
    return res?.msg;
  }

  return {
    total,
    orders,
    getOrders,
  };
}
